package org.catspaw.cherubim.persistence.dao.spring.jdbc;

import org.catspaw.cherubim.persistence.dao.UpdateDao;
import org.catspaw.cherubim.persistence.spring.jdbc.SuitableParameterBatchPreparedStatementSetter;
import org.catspaw.cherubim.persistence.spring.jdbc.SuitableParameterPreparedStatementSetter;
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
import org.springframework.jdbc.core.support.JdbcDaoSupport;

public class UpdateSpringJdbcDao extends JdbcDaoSupport implements UpdateDao {

	public Object update(String sql, Object... params) {
		return getJdbcTemplate().update(sql, new SuitableParameterPreparedStatementSetter(params));
	}

	public Object batch(String sql, Object[][] params) {
		BatchPreparedStatementSetter setter = new SuitableParameterBatchPreparedStatementSetter(
				params);
		return getJdbcTemplate().batchUpdate(sql, setter);
	}

	public Object batch(String sql, Object[][] params, int batchSize) {
		throw new UnsupportedOperationException("unsupported operation...");
	}
}
